Skip to content

ci: fix the random "has no dist/convertapi.d.ts" (tar | grep -q under pipefail) - #31

Merged
tomasr78 merged 1 commit into
mainfrom
ci/fix-sigpipe-race
Nov 9, 2026
Merged

tomasr78 merged 1 commit into
mainfrom
ci/fix-sigpipe-race

Conversation

@tomasr78

@tomasr78 tomasr78 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Why

The main Build of df2759a failed on 2026-11-09 in Pack (run 42633356489, attempt 1):

tar: stdout: write error
##[error]out/convertapi-js-0.0.0-ci.12.gdf2759a.tgz has no dist/convertapi.d.ts

npm's own file list for that tarball contains dist/convertapi.d.ts, and attempt 2 passed. #30 failed the same way once before a rerun passed.

The check was tar -tzf "$TGZ" | grep -qx "package/$f" under set -euo pipefail:

  1. GNU tar writes the listing one line per write() (strace: 33 writes for this 31-file tarball, where dist/convertapi.d.ts is entry 25).
  2. grep -q exits as soon as it matches.
  3. tar's next write gets EPIPE. The runner ignores SIGPIPE, so tar prints stdout: write error and exits 2.
  4. pipefail fails the pipeline, and the || prints a false "has no …".

The "Check the package" step in publish.yml has the same line, so a release could stop the same way.

Change

Both steps list the tarball once into $RUNNER_TEMP/tgz-files.txt and grep that file. The error messages are unchanged. A tarball that tar cannot read now stops the step with tar's own error instead of "has no …".

Dropping -q and sending grep's output to /dev/null would also work with GNU grep, which drains its input in that case, but the file doesn't depend on that.

Tested

In an Ubuntu 24.04 container (GNU tar 1.35, GNU grep 3.11, bash 5.2) with SIGPIPE ignored, as on the runner. Each step's run: script was read from the workflow file and run with bash -euo pipefail against the package built from main (npm ci, npm run build, npm pack), with npm stubbed to hand over that tarball:

Case main this branch
Pack, complete package, 500 runs 11 failed (tar: stdout: write error, then "has no …") 0 failed
Check the package, complete package, 500 runs 9 failed (same) 0 failed
Pack, tarball without dist/convertapi.d.ts exit 1, ::error::out/convertapi-js-0.0.0-ci.12.gdf2759a.tgz has no dist/convertapi.d.ts same
Pack, tarball without dist/convertapi.js exit 1, ::error::… has no dist/convertapi.js same
Check the package, tarball without dist/convertapi.d.ts exit 1, ::error::out/convertapi-js-9.9.9-local.1.tgz has no dist/convertapi.d.ts same

This PR's own Build runs the new Pack step. publish.yml runs only on a release, so it was tested only as above.

Same fix for the release check in ConvertAPI/convertapi-library-node#128. The same defensive change, where nothing fails today: ConvertAPI/convertapi-library-python#65 and ConvertAPI/convertapi-library-java#61.

🤖 Generated with Claude Code

`tar -tzf "$TGZ" | grep -qx "package/$f"` under pipefail failed at random:
GNU tar writes the listing one line per write(), grep -q exits at its
match, tar's next write fails ("tar: stdout: write error", exit 2), and
pipefail turns that into "has no dist/convertapi.d.ts". The main Build of
df2759a failed this way on 2026-11-09 (run 42633356489, attempt 1).

Pack (build.yml) and "Check the package" (publish.yml) now list the
tarball into $RUNNER_TEMP once and grep the file. The error messages are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the build and release package-validation changes.

No open issues 🎉

What changed in this PR

Fixes intermittent package-validation failures in the build and release workflows caused by grep -q closing a pipe while tar is still writing under pipefail.

Changes:

  • Saves the tarball listing to a temporary file before checking required package files.
  • Preserves missing-file error messages while allowing tar read failures to surface directly.
File Description
.github/​workflows/​publish.yml Uses a saved tarball listing for release package validation.
.github/​workflows/​build.yml Uses a saved tarball listing for build package validation.

Review effort: Balanced

@tomasr78
tomasr78 merged commit 080d07e into main Nov 9, 2026
5 checks passed
@tomasr78
tomasr78 deleted the ci/fix-sigpipe-race branch November 9, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants